#pragma once

#ifndef MARKETDATAFILTER_H
#define MARKETDATAFILTER_H

#include "SmartTrade\SmartTradecUserApiStruct.h"
#include "MarketDataApiType.h"
#include "Instrument.h"
#include "../SmartTrade.ComplexEventEngine/SmartTradeEventSystem.h"

#include <set>
#include <string>
#include <loki\Singleton.h>
#include <loki\SmartPtr.h>

using namespace std;

namespace SmartTrade{
	
	class MarketDataFilter
	{
	public:
		MarketDataFilter(void);
		MarketDataFilter(const Ptr_InstrumentMap pInstMap);
		~MarketDataFilter(void);
	public:
		void SetInstrumentMap(const Ptr_InstrumentMap pInstMap);
		void FilterData(const Ptr_DepthMarketData pDepthMarketData);
	private:
		Ptr_Instrument GetInstrument(string& strInstrumentId);
		void FilterQuote(const Ptr_Instrument pInstrument,const Ptr_Date pDate,const Ptr_DepthMarketData pDepthMarketData);
		void FilterTrade(const Ptr_Instrument pInstrument,const Ptr_Date pDate,const Ptr_DepthMarketData pDepthMarketData);
		void FilterBar(const Ptr_Instrument pInstrument);
		void FilterPairData(const Ptr_Instrument pInstrument);
		void FilterPairQuoteData(const Ptr_Instrument pFirstInstrument,const Ptr_Instrument pSecondInstrument);
		void FilterPairTradeData(const Ptr_Instrument pFirstInstrument,const Ptr_Instrument pSecondInstrument);
		void FilterPairCloseBarData(Ptr_Instrument pFirstInstrument,const Ptr_Instrument pSecondInstrument);
		void RegisterBarEvent();
		void On_BarOpen(const Ptr_Instrument pInstrument,const Ptr_Bar pBar);
		void On_BarClose(const Ptr_Instrument pInstrument,const Ptr_Bar pBar);
	private:
		Ptr_InstrumentMap pInstMap_;
	};
	typedef Loki::SmartPtr<MarketDataFilter> Ptr_MarketDataFilter;
}
#endif // MARKETDATAFILTER_H

